package ghostcat.util
{
    import flash.utils.*;

    final public class Util extends Object
    {

        public function Util()
        {
            return;
        }// end function

        public static function equal(param1, param2) : Boolean
        {
            var _loc_3:* = new ByteArray();
            _loc_3.writeObject(param1);
            _loc_3.position = 0;
            var _loc_4:* = new ByteArray();
            new ByteArray().writeObject(param2);
            _loc_4.position = 0;
            if (_loc_3.length == _loc_4.length)
            {
                while (_loc_3.bytesAvailable)
                {
                    
                    if (_loc_3.readByte() != _loc_4.readByte())
                    {
                        return false;
                    }
                }
            }
            else
            {
                return false;
            }
            return true;
        }// end function

        public static function isEmpty(param1) : Boolean
        {
            var _loc_2:* = undefined;
            for (_loc_2 in param1)
            {
                
                return false;
            }
            return true;
        }// end function

        public static function remove(param1, param2) : void
        {
            var _loc_3:int = 0;
            var _loc_4:* = undefined;
            if (param1 is Array)
            {
                _loc_3 = (param1 as Array).indexOf(param2);
                if (_loc_3 != -1)
                {
                    (param1 as Array).splice(_loc_3, 1);
                }
            }
            else
            {
                for (_loc_4 in param1)
                {
                    
                    if (param1[_loc_4] == param2)
                    {
                        delete param1[_loc_4];
                        return;
                    }
                }
            }
            return;
        }// end function

        public static function removeXMLNote(param1:XML) : void
        {
            delete param1.parent().*[param1.childIndex()];
            return;
        }// end function

        public static function doAll(param1:Function, param2:Array) : Array
        {
            var _loc_3:Array = [];
            var _loc_4:int = 0;
            while (_loc_4 < param2.length)
            {
                
                _loc_3.push(Util[param1](param2[_loc_4]));
                _loc_4++;
            }
            return _loc_3;
        }// end function

        public static function createObject(param1, param2:Object)
        {
            var _loc_3:* = undefined;
            if (param1 is Class)
            {
                param1 = new param1;
            }
            for (_loc_3 in param2)
            {
                
                param1[_loc_3] = param2[_loc_3];
            }
            return param1;
        }// end function

        public static function copy(param1, param2 = null)
        {
            var _loc_3:* = undefined;
            if (!param2)
            {
                param2 = new Object();
            }
            for (_loc_3 in param1)
            {
                
                param2[_loc_3] = param1[_loc_3];
            }
            return param2;
        }// end function

        public static function clone(param1)
        {
            var _loc_2:* = new ByteArray();
            _loc_2.writeObject(param1);
            _loc_2.position = 0;
            return _loc_2.readObject();
        }// end function

        public static function unionObject(param1:Object, param2:Object) : Object
        {
            var _loc_4:* = undefined;
            var _loc_3:* = new Object();
            for (_loc_4 in param1)
            {
                
                _loc_3[_loc_4] = param1[_loc_4];
            }
            for (_loc_4 in param2)
            {
                
                _loc_3[_loc_4] = param2[_loc_4];
            }
            return _loc_3;
        }// end function

        public static function isIn(param1, param2:Array) : Boolean
        {
            if (param2 == null)
            {
                return false;
            }
            var _loc_3:int = 0;
            while (_loc_3 < param2.length)
            {
                
                if (param1 is param2[_loc_3])
                {
                    return true;
                }
                _loc_3++;
            }
            return false;
        }// end function

    }
}
